package com.nbsaas.boot.tenant.rest.resource;

import com.nbsaas.boot.tenant.api.apis.DatabaseApi;
import com.nbsaas.boot.tenant.data.entity.Database;
import com.nbsaas.boot.tenant.api.domain.request.DatabaseRequest;
import com.nbsaas.boot.tenant.api.domain.response.DatabaseResponse;
import com.nbsaas.boot.tenant.api.domain.simple.DatabaseSimple;
import com.nbsaas.boot.tenant.rest.convert.DatabaseSimpleConvert;
import com.nbsaas.boot.tenant.rest.convert.DatabaseEntityConvert;
import com.nbsaas.boot.tenant.rest.convert.DatabaseResponseConvert;
import com.nbsaas.boot.tenant.data.repository.DatabaseRepository;

import java.io.Serializable;
import com.nbsaas.boot.jpa.data.core.BaseResource;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import org.springframework.data.jpa.repository.support.JpaRepositoryImplementation;

import java.util.function.Function;
/**
*   数据源管理-业务接口实现
*/
@Transactional
@Service
public class DatabaseResource extends BaseResource<Database,DatabaseResponse, DatabaseSimple, DatabaseRequest>  implements DatabaseApi {

    @Resource
    private DatabaseRepository databaseRepository;

    @Override
    public JpaRepositoryImplementation<Database, Serializable> getJpaRepository() {
        return databaseRepository;
    }

    @Override
    public Function<Database, DatabaseSimple> getConvertSimple() {
        return new DatabaseSimpleConvert();
    }

    @Override
    public Function<DatabaseRequest, Database> getConvertForm() {
        return new DatabaseEntityConvert();
    }

    @Override
    public Function<Database, DatabaseResponse> getConvertResponse() {
        return new DatabaseResponseConvert();
    }




}


